package com.wlw.eye.mvp.presenter

import android.content.Context
import com.wlw.eye.mvp.contract.ResultContract
import com.wlw.eye.mvp.model.ResultModel
import com.wlw.eye.utils.applyScheduler

class ResultPresenter(context: Context, view: ResultContract.View) : ResultContract.Presenter {
    var context: Context? = null
    var mView: ResultContract.View? = null
    val mModel: ResultModel by lazy {
        ResultModel()
    }

    init {
        this.context = context
        this.mView = view
    }

    override fun requestData(query: String, start: Int) {
        val observable = context?.let { mModel.loadData(it, query, start) }
        observable?.applyScheduler()?.subscribe {
            mView?.setData(it)
        }
    }

    override fun start() {
    }
}